<?php
require_once (APPLICATION_DIR."/library/external/XOAD/xoad.php");
class AdminalumnigeneralController extends DRX_Controller
{
	function xoadGetMeta()
	{
		XOAD_Client::mapMethods($this,array("listindustry", "addindustry", "updateindustry", "listlocation", "addlocation", "updatelocation", "listintake", "addintake", "updateintake"));
	}
	
	function updateintake($p_arrArgs)
	{
		$objGeneral = new AlumniGeneral();
		if ( $objGeneral -> updateIntake($p_arrArgs) )
			return "SUCCESS";
		else
			return "FAIL";
	}
	
	function addintake($p_arrArgs)
	{
		$objGeneral = new AlumniGeneral();
		if ( $objGeneral -> addIntake($p_arrArgs) )
			return "SUCCESS";
		else
			return "FAIL";
	}
	
	function listintake($p_arrArgs)
	{
		$objSmarty = DRX::load('smarty');
		$objGeneral = new AlumniGeneral();
		$arrIntake = $objGeneral -> getListIntake();
		
		$objSmarty -> assign("arrIntake", $arrIntake);
		XOAD_HTML::getElementById($p_arrArgs['id']) -> innerHTML = $objSmarty -> fetch("admin/alumni/general/list_intake.tpl");
	}
	
	function updatelocation($p_arrArgs)
	{
		$objGeneral = new AlumniGeneral();
		if ( $objGeneral -> updateLocation($p_arrArgs) )
			return "SUCCESS";
		else
			return "FAIL";
	}
	
	function addlocation($p_arrArgs)
	{
		$objGeneral = new AlumniGeneral();
		if ( $objGeneral -> addLocation($p_arrArgs["location_name"]) )
			return "SUCCESS";
		else
			return "FAIL";
	}
	
	function listlocation($p_arrArgs)
	{
		$objSmarty = DRX::load('smarty');
		$objGeneral = new AlumniGeneral();
		$arrLocation = $objGeneral -> getListLocation();
		
		$objSmarty -> assign("arrLocation", $arrLocation);
		XOAD_HTML::getElementById($p_arrArgs['id']) -> innerHTML = $objSmarty -> fetch("admin/alumni/general/list_location.tpl");
	}
	
	
	function updateindustry($p_arrArgs)
	{
		$objGeneral = new AlumniGeneral();
		if ( $objGeneral -> updateIndustry($p_arrArgs) )
			return "SUCCESS";
		else
			return "FAIL";
	}
	
	function addindustry($p_arrArgs)
	{
		$objGeneral = new AlumniGeneral();
		if ( $objGeneral -> addIndustry($p_arrArgs["industry_name"]) )
			return "SUCCESS";
		else
			return "FAIL";
	}
	
	function listindustry($p_arrArgs)
	{
		$objSmarty = DRX::load('smarty');
		$objGeneral = new AlumniGeneral();
		$arrIndustry = $objGeneral -> getListIndustry();
		
		$objSmarty -> assign("arrIndustry", $arrIndustry);
		XOAD_HTML::getElementById($p_arrArgs['id']) -> innerHTML = $objSmarty -> fetch("admin/alumni/general/list_industry.tpl");
	}
	
	
	function indexAction()
	{
		//$this -> listAction();
		$objSmarty = DRX::load('smarty');
		$this -> runXoadServer();
		$this -> pathWeb();
		$this -> getLeftMenu();
		$objSmarty -> assign("content", $objSmarty -> fetch("admin/alumni/general/index.tpl"));
		$objSmarty->display("admin/admin.tpl");
	}
	
	function getLeftMenu()
	{
		$objSmarty = DRX::load('smarty');		
		$objSmarty -> assign("leftmenu", $objSmarty -> fetch("admin/alumni/general/left_menu.tpl"));
	}
	
	function createFCK($p_strName, $p_strValue = "")
	{
		$oFCKeditor = new FCKeditor($p_strName) ;
		$oFCKeditor->BasePath = FCK_BASE_PATH;
		$oFCKeditor->Height = FCK_DEFAULT_HEIGHT;
		$oFCKeditor->Value = $p_strValue;
		$fck = $oFCKeditor->Create();
		return $fck;
	}
	
	function pathWeb()
	{
		$objSmarty = DRX::load('smarty');
		$list_path = array();
		$prefix_url             = APPLICATION_URL . ADMIN_URL;        
    $list_path[0]['url']    = $prefix_url;
    $list_path[0]['title']  = ADMIN_HOME_PATH_WEB_TITLE;
		$last_path['url']    = $prefix_url . "/alumni/general";
    $last_path['title']  = "General Management";
		
		$objSmarty -> assign("list_path",$list_path);
		$objSmarty -> assign("last_path",$last_path);
		$path_web = $objSmarty->fetch("admin/path_web.tpl");
	  $objSmarty -> assign("path_web",$path_web);
	}
	
	function runXoadServer()
	{
		$objSmarty = DRX::load('smarty');
		
		if ( XOAD_Server::runServer() )
		{
			exit();
		}
		
		$objSmarty -> assign("xoad_header", XOAD_Utilities::header(APPLICATION_URL . "library/external/XOAD"));	
		$objSmarty -> assign("xoad_handler", XOAD_Client::register($this, "/Adminalumnigeneral"));
	}	
}

?>